package com.tbit.uqbike.webmanager.controller;

import com.tbit.uqbike.object.pojo.MachineAbnormal;
import com.tbit.uqbike.object.value.LoginInfo;
import com.tbit.uqbike.object.view.JsonResult;
import com.tbit.uqbike.service.rpcservice.MachineAbnormalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 故障异常
 *
 * @author Leon
 * 2019年11月16日 下午3:11:00
 */
@Validated
@RestController
@RequestMapping("/machineAbnormal")
public class MachineAbnormalController extends BaseController {
    @Autowired
    private MachineAbnormalService machineAbnormalService;

    /* 根据设备编号查询*/
    @RequestMapping("/getByMachineId")
    public JsonResult getByMachineId(@NotNull(message = "ver.machineId.notNull") Integer machineId, HttpServletRequest request) {
        LoginInfo info = getLogin(request);

        List<MachineAbnormal> machineAbnormals = machineAbnormalService.getByMachineId(info, machineId);

        return JsonResult.ok(machineAbnormals);
    }

}